#include "radar_widget_base.h"
#include "../../config/app_config.h"
#include "../radar.h"
#include <boost/bind.hpp>
double RadarWidgetBase::jiaodu_xiuzheng_=0;
Radar * RadarWidgetBase::m_radar(nullptr);
RadarWidgetBase::RadarWidgetBase(QWidget *parent)
    : QDialog(parent)
{
}

RadarWidgetBase::~RadarWidgetBase()
{

}

void RadarWidgetBase::SetRadar(Radar *radar, bool add_cb)
{
    m_radar = radar;

    if (add_cb)
    {
        m_radar->AddRadarStatusCallback(boost::bind(&RadarWidgetBase::StatusMsgReceive, this, _1, _2, _3));
    }

    connect(this, SIGNAL(RadarStatusMsg(const std::string&, unsigned int)), this, SLOT(MsgSlot(const std::string&, unsigned int)));
}

void RadarWidgetBase::AzimuthModifyChanged(double val)
{
    jiaodu_xiuzheng_ = val;
    m_radar->SetAzimuthModify(val);

    sln_app_config::instance().set_radar_azimuth_modify(val);
}

void RadarWidgetBase::RangeModifyChanged(double val)
{
    m_radar->SetRangeModify(val);

    sln_app_config::instance().set_radar_range_modify(val);
}

void RadarWidgetBase::StatusMsgReceive(const char * data, unsigned int length, unsigned int radar_key)
{
    emit RadarStatusMsg(std::string(data, length), radar_key);
}

void RadarWidgetBase::MsgSlot(const std::string& str, unsigned int radar_key)
{
    //todo ״̬
}